#include <bits/stdc++.h>
using namespace std;



int main()
{
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
	int t;
	cin >> t;
	for(int k = 1;k <= t;k++)
	{
		int a[100005]={0};
		int b[100005]={0};
		int maxn = 0,minn = 100005;
		int n;
		int jsq = 0;
		cin >> n;
		for(int i = 1;i <= n;i++)
		{
			cin >> a[i];
			b[a[i]]++;
			if(a[i] > maxn) maxn = a[i];
			if(a[i] < minn) minn = a[i];
		}
		for(int i = minn;i <= maxn;i++)
		{
			if(b[i] > 1) jsq +=i;
		}
		cout << jsq << endl;
	}
	
	return 0;
}
